package org.lsb.app_back.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.lsb.app_back.interceptor.JwtTokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.w3c.dom.ls.LSOutput;

@Configuration
@Slf4j
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private JwtTokenInterceptor jwtTokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册 JWT 令牌校验拦截器
        // 拦截所有需要验证的接口，例如 /appInfo 下的所有接口
        log.info("开始注册自定义拦截器...");
        registry.addInterceptor(jwtTokenInterceptor)
                .excludePathPatterns(
                        "/user/login",
                        "/appCategory/hi",
                        "/appCategory/tree",
//                        "/webjars/**",
//                        "/doc.html",
//                        "swagger-resources",
//                        "/v3/**","doc.html#/**"
                        "/swagger-ui.html","/swagger-resources/**","/webjars/**","/swagger-ui/**","/v3/api-docs/**","/doc.html"
                );// 只排除登录接口
    }
}